package user.service.impl;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import javax.jws.WebService;

import user.entity.User;
import user.service.AddUserException;
import user.service.UserService;

/**
 * 手动编写接口和接口实现类，发布应用后，自动生成wsdl
 * @author ddf 2016年10月9日下午2:13:46
 */
@WebService(endpointInterface="user.service.UserService")
public class UserServiceImpl implements UserService{
	private Map<String, User> userMap = new HashMap<String, User>();
	
	@Override
	public void addUser(User user) throws AddUserException {
		if(userMap.get(user.getUsername()) == null) {
			userMap.put(user.getUsername(), user);
		} else {
			throw new AddUserException("用户已经存在！");
		}
	}

	@Override
	public void deleteUser(String username) {
		userMap.remove(username);
	}

	@Override
	public Collection<User> getAllUser() {
		return userMap.values();
	}
}
